<?php

require_once('db_connection.php');

  pr($_GET);
  pr1($_POST);

if(isset($_POST['name'])) {
   /******* start query  *********/
    $where = "WHERE `id`= '$_POST[id]'";
    $updated_rows = update('users',$_POST,$where);
    /******* end query  *********/
}


  // if set in URL then update
  if(isset($_GET['id'])) {
    $id = $_GET['id'];
  } else {
    header('location:http://localhost/try/show_all_users.php');
    exit;
  }

  $user = fetchById('users',$id);

  $isActive = ($user['status']==1)?'checked':'';
  $isInactive = ($user['status']==0)?'checked':'';

  pr($user);
?>
<link href="../html/css/site.css" rel="stylesheet" type="text/css" />

<form action="" method="post">

<input type="text" name="id" value="<?=$user['id']?>" id="" />

  <table border="0" width="80%" align="center"cellspacing ="0">
    <thead>
      <tr>
        <th colspan="2">::Edit User Details::</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right">Name :</td>
        <td><input type="text" name="name" value="<?=$user['name']?>" /></td>
      </tr>
      <tr>
        <td align="right">Email :</td>
        <td><input type="text" name="email" value="<?=$user['email']?>" /></td>
      </tr>
      <tr>
        <td align="right">Added date :</td>
        <td><?=$user['added_date']?></td>
      </tr>
      <tr>
        <td align="right">Modified Date :</td>
        <td><?=$user['modified_date']?></td>
      </tr>
      <tr>
        <td align="right">Status :</td>
        <td>
  <label><input <?=$isInactive?> type="radio" name="status" value="0" />Inactive</label>
  <label><input <?=$isActive?> type="radio" name="status" value="1" />Active</label>
        </td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td><input type="submit" value="Update"> </td>
      </tr>
    </tbody>
  </table>

</form>


